"use client";

import PageFooter from "@/components/page-footer";
import PageHeader from "@/components/page-header";
import User from "@/shared/user";
import React, { createContext, useState } from "react";
import { ToastContainer } from "react-toastify";

export const UserCtx = createContext<{
  user: User | null;
  setUser: (user: User) => void;
}>({
  user: null,
  setUser: () => {},
});

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  const [user, setUser] = useState<User | null>(null);

  return (
    <div style={{ display: "flex", flexDirection: "column", height: "100vh" }}>
      <UserCtx.Provider value={{ user: user, setUser }}>
        <PageHeader />
        {children}
        <PageFooter />
      </UserCtx.Provider>
      <ToastContainer limit={5} />
    </div>
  );
}
